yyy<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/9/27
 * Time: 上午11:07
 */


if (!isset($_GET['id'])){
    die("缺少关键参数ID");
}
$id = $_GET["id"];
//1.连接数据库
try{
    $pdo = new PDO("mysql:host=127.0.0.1;dbname=test0926","root","");
}catch (PDOException $e){
    echo "连接失败";
    var_dump($e);
}

//2.组合SQL删除语句
$delSQL = "DELETE FROM tb_comment WHERE id = $id";

//3.执行语句(增删改建议使用exec(返回一个整型) 查询query)
$res = $pdo -> exec($delSQL);

//4.提示成功或失败
if ($res > 0){
    echo "删除成功,1秒后会跳转回去";
    //跳转 demo1.php ,并且刷新那个页面即可
//    header('Location:demo1.php');
//    exit;
echo '<meta http-equiv="refresh" content="1;url=demo1.php">';//修改


}else{
    echo "删除失败";
    var_dump($pdo->errorInfo());
}

